﻿using System;
using System.Collections.Generic;
using UnityEngine;

// Token: 0x02000225 RID: 549
public class H_Light : MonoBehaviour
{
	// Token: 0x06000ECF RID: 3791 RVA: 0x0005CB58 File Offset: 0x0005AD58
	public void ChangeMap(string map_name)
	{
		this.styleLights.Clear();
		string assetName = "H_Light_" + map_name;
		string assetBundleName = "h/h_light";
		TextAsset textAsset = AssetBundleLoader.LoadAsset<TextAsset>(GlobalData.assetBundlePath, assetBundleName, assetName);
		if (textAsset != null)
		{
			ListDataLoader listDataLoader = new ListDataLoader('\t', StringSplitOptions.None);
			listDataLoader.Load_Text(textAsset, -1, -1);
			for (int i = 0; i < listDataLoader.Y_Num; i++)
			{
				string text = listDataLoader.Get(0, i);
				if (text.Length > 0)
				{
					H_Light.StyleLight styleLight = new H_Light.StyleLight(listDataLoader, i);
					if (this.styleLights.ContainsKey(styleLight.styleName))
					{
						GlobalData.Debug_LogError("重复键: " + styleLight.styleName);
					}
					else
					{
						this.styleLights.Add(styleLight.styleName, styleLight);
					}
				}
			}
		}
	}

	// Token: 0x06000ED0 RID: 3792 RVA: 0x0005CC34 File Offset: 0x0005AE34
	public Vector3 Get(string id, int no)
	{
		Vector3 zero = Vector3.zero;
		if (this.styleLights.ContainsKey(id))
		{
			H_Light.StyleLight styleLight = this.styleLights[id];
			if (no < styleLight.dir.Count)
			{
				return styleLight.dir[no];
			}
		}
		return zero;
	}

	// Token: 0x04000F88 RID: 3976
	private Dictionary<string, H_Light.StyleLight> styleLights = new Dictionary<string, H_Light.StyleLight>();

	// Token: 0x02000226 RID: 550
	private class StyleLight
	{
		// Token: 0x06000ED1 RID: 3793 RVA: 0x0005CC84 File Offset: 0x0005AE84
		public StyleLight(ListDataLoader loader, int y)
		{
			this.styleName = loader.Get(0, y);
			for (int i = 0; i < 3; i++)
			{
				int num = i * 4 + 1;
				string text = loader.Get(num, y);
				string text2 = loader.Get(num + 1, y);
				if (text.Length == 0 || text2.Length == 0)
				{
					break;
				}
				float x = this.StrToFloat(text);
				float y2 = this.StrToFloat(text2);
				this.dir.Add(new Vector3(x, y2, 0f));
			}
		}

		// Token: 0x06000ED2 RID: 3794 RVA: 0x0005CD28 File Offset: 0x0005AF28
		private float StrToFloat(string str)
		{
			float result = 0f;
			try
			{
				result = float.Parse(str);
			}
			catch
			{
				GlobalData.Debug_LogError("不能转换成数字:" + str);
			}
			return result;
		}

		// Token: 0x04000F89 RID: 3977
		public string styleName;

		// Token: 0x04000F8A RID: 3978
		public List<Vector3> dir = new List<Vector3>();
	}
}
